﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Guline.Web.CentralModels.Object;
using Guline.Web.Central.Controllers;
namespace Guline.Web.Central.Areas.Api.Controllers
{
    public class MessageController : BaseController
    {
        public ActionResult UpdateMessage(int MessageID,string Status)
        {
            var msg = db.Messages.Where(m => m.ID == MessageID).FirstOrDefault();
            if (msg == null)
            {
                return Json(new { success = false, info = new { error="Message not found"} }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                msg.Status = 1;
                msg.DateSent = DateTime.Now;
                db.SaveChanges();
                return Json(new { success = true }, JsonRequestBehavior.AllowGet);
            }
        }
    }
}
